<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title></title>
	<style>
		table{
			border-collapse: collapse;
			font-family: "微软雅黑","Microsoft Yahei";
			font-size: 14px;
		}
		td{
			border: 1px solid #ccc;
		
			height: 30px;

		}
	</style>
</head>
<body>
	<table>
		<tr>
			<td>序号</td>
			<td>书名</td>
		</tr>
		<tr>
			<td>1</td>
			<td>《JavaScript高级程序设计》</td>
		</tr>
		<tr>
			<td>1</td>
			<td>《JavaScript高级程序设计》</td>
		</tr>
		<tr>
			<td>1</td>
			<td>《JavaScript高级程序设计》</td>
		</tr>
	</table>
	<script>
		var arr = [["序号","书名"],[1,"《JavaScript高级程序设计》"],[2,"《DOM编程艺术》"],[3,"《编程之美》"],[4,"《Thinking in java》"],[5,"《大头儿子和小头爸爸》"]];
		// var arr = ["数组1","数组2","数组3"]
		//生成一个表格
		/*
			1生成table 
				var table = "<table>"
					//生成tr  td
					
				table +="</table>"
			2循环生成tr
				var table = "<table>";
				for(var i = 0;i<arr.length;i++){
					table +="<tr>";

						//生成td

					table +="</tr>";
				}
				table+="</table>"
			3循环生成td
				var table = "<table>";
				for(var i = 0;i<arr.length;i++){
					table +="<tr>";

						for(var j = 0;j<arr[i].length;j++){
							table += "<td>"+ arr[i][j] +"</td>";
						}

					table +="</tr>";
				}


				table+="</table>"
				console.log(table);
		*/

		var table = "<table>";
		for(var i = 0;i<arr.length;i++){
			table +="<tr>";

				for(var j = 0;j<arr[i].length;j++){
					table += "<td>"+ arr[i][j] +"</td>";
				}

			table +="</tr>";
		}


		table+="</table>"
		console.log(table);
		document.write(table);

	</script>
</body>
</html>